<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>密码生成器</title>
        <meta name="viewport" content="initial-scale=1.0, maximum-scale=2.0, minimum-scale=1.0, user-scalable=yes, width=device-width" />
        <meta content="密码,生成,器,密码生成器" name="Keywords" />
        <meta content="密码生成器" name="Description" />
        <meta content="IE=EmulateIE7" http-equiv="X-UA-Compatible" />
        <link href="css/css.css" rel="stylesheet" type="text/css" />
        <script language="JavaScript" src="js/jquery-1.7.1.min.js"></script>
        <script language="JavaScript">
            function getRandomNum(lbound, ubound) {
                return (Math.floor(Math.random() * (ubound - lbound)) + lbound);
            }
            function getRandomChar() {
                var numberChars = "0123456789";
                var lowerChars = "abcdefghijklmnopqrstuvwxyz";
                var upperChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
                var otherChars = "+=-@#~,.[]()!%^*$";
                var charSet = "";
                if (document.f1.number.checked == true)
                    charSet += numberChars;
                if (document.f1.lowerChars.checked == true)
                    charSet += lowerChars;
                if (document.f1.upperChars.checked == true)
                    charSet += upperChars;
                if (document.f1.otherChars.checked == true)
                    charSet += otherChars;
                var i = getRandomNum(0, charSet.length);
                return charSet.charAt(i);
            }
            function getPassword() {
                var length = document.f1.charlength.value;
                if (!(length >= 1 && length <= 32)) {
                    length = 16;
                    document.f1.charlength.value = 16;
                }
                var rc = "";
                if (length > 0)
                    rc = rc + getRandomChar();
                for (var idx = 1; idx < length; ++idx) {
                    rc = rc + getRandomChar();
                }
                document.f1.result.value = rc;
            }
            function copy() {
                var v = document.f1.result.value;
                if (v == "") {
                    getPassword();
                    v = document.f1.result.value;
                }
                if (window.clipboardData) {
                    window.clipboardData.clearData();
                    window.clipboardData.setData("Text", v);
                    //$("#apDiv1").show();
                    showMsg("已经复制到粘贴板，请使用ctrl+v粘贴到你需要的位置。");
                }
                else {
                    $(".xia").select();
                    //showMsg("您使用的是非IE核心浏览器，请按下Ctrl+C复制密码到剪贴板");
                    document.execCommand('copy');
                    showMsg("已经复制到粘贴板，请使用ctrl+v粘贴到你需要的位置。");
                }
            }
            function showMsg(msg) {
                $("#msg").html(msg);
                $("#apDiv1").show();
                setTimeout("close()", 1000);
            }
            function close() {
                $("#apDiv1").fadeOut(1000);
            }
        </script>
    </head>

    <body >
        <div class="box">
            <div class="top"></div> 
            <div class="warp">
                <form name="f1" id="f1">
                    <div class="zjbeijing" >

                        <div class="biaoti" \><img src="images/one.jpg"></div>
                        <div class="title">
                            <input name="charlength" type="text" class="xian" size="36" maxlength="2" value="16" style="" />
                            <label class="company">&nbsp;(最小1位，最大32位)</label></div>
                        <div class="biaoti"><img src="images/two.jpg"></div>

                        <div class="biaoti_title">          
                            <ul>
                                <li><label><input type="checkbox" value="" checked="checked" name="number" />阿拉伯数字</label></li>
                                <li><label><input type="checkbox" value="" checked="checked" name="lowerChars" />小写字母</label></li>
                                <li><label><input type="checkbox" value="" checked="checked" name="upperChars" />大写字母</label></li>
                                <li><label><input type="checkbox" value="" name="otherChars" />特殊字符 +=-@#~,.[]()!%^*$</label></li>
                            </ul>
                        </div> 
                        <div class="biaoti" ><img src="images/three.jpg"></div>
                        <div class="title">      
                            <input name="result" type="text" class="xia" size="36" />
                        </div>
                        <div class="juzhong">
                            <div align="center"><span style="padding-right: 40px; padding-top:10px;"><a href="javascript:getPassword();">
                                        <img src="images/produce.jpg" onmouseout="this.src = 'images/produce.jpg'" onmouseover="this.src = 'images/produce_1.jpg'" /></a></span> <span><a href="javascript:copy();">
                                        <img src="images/copy.jpg"  onmouseout="this.src = 'images/copy.jpg'" onmouseover="this.src = 'images/copy_1.jpg'"/></a></span>
                            </div>
                        </div>
                    </div>
                    <div>
                    </div>
                    <div id="apDiv1" style=" display:none">
                        <div class="maskcontent">
                            <div style="color: rgb(0, 0, 0); float: left; padding-left: 28px;" id="msg">已经复制到粘贴板，请使用ctrl+v粘贴到你需要的位置。</div>
                        </div>
                    </div>
                </form>
            </div>    
        </div>
    </body>
</html>

